package com.yuntian.mapper;

import com.yuntian.entity.Company;
import org.apache.ibatis.annotations.*;
import java.util.List;
import java.math.BigDecimal;

public interface CompanyMapper {

    // 新增公司
    @Insert("INSERT INTO company (" +
            "company_id, company_name, legal_person, business_scope, established_on, " +
            "address, phone, intro, intro_image_url, create_time, update_time" +
            ") VALUES (" +
            "#{companyId}, #{companyName}, #{legalPerson}, #{businessScope}, #{establishedOn}, " +
            "#{address}, #{phone}, #{intro}, #{introImageUrl}, #{createTime}, #{updateTime}" +
            ")")
    int insert(Company company);

    // 根据ID删除公司
    @Delete("DELETE FROM company WHERE company_id = #{companyId}")
    int deleteById(BigDecimal companyId);

    // 根据ID更新公司
    @Update("UPDATE company SET " +
            "company_name = #{companyName}, " +
            "legal_person = #{legalPerson}, " +
            "business_scope = #{businessScope}, " +
            "established_on = #{establishedOn}, " +
            "address = #{address}, " +
            "phone = #{phone}, " +
            "intro = #{intro}, " +
            "intro_image_url = #{introImageUrl}, " +
            "create_time = #{createTime}, " +
            "update_time = #{updateTime} " +
            "WHERE company_id = #{companyId}")
    int updateById(Company company);

    // 根据ID查询公司
    @Select("SELECT * FROM company WHERE company_id = #{companyId}")
    Company selectById(BigDecimal companyId);

    // 查询所有公司
    @Select("SELECT * FROM company")
    List<Company> selectAll();
}